﻿using Checc_CircularCulvert_Assemble.commons;
using Checc_CircularCulvert_Assemble.commons.overall;
using static Bentley.CIMNET.CIMGeometry.Solid.SolidUtil.Modify;
using GeneralHelpers = CheccCoverplateCulvertAssemble.Tools.GeneralBank;

namespace Checc_CircularCulvert_Assemble.structures
{
    /// <summary>
    /// 进口急流槽构建
    /// </summary>
    public class ChuteInStructure
    {
        public List<Element> Elements { get; set; } = new List<Element>();
        public void CreateChuteInStructure(CommonChuteIn commonChuteIn, double angle, double culvertOpeningWidth, double wallThickness, double endWallHeight, DgnModel dgnModel)
        {

            CreateWells(
                commonChuteIn.ShaftBottomCentreLength * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftBottomEndlongSlope,
                commonChuteIn.ShaftBottomBaseThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BaseEdgeThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftWallSlopeRatio,
                commonChuteIn.TopWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.GritBasinDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BottomPaveThickness * 0.01 * GeneralHelpers.UorToMeters,
                angle,
               culvertOpeningWidth,
               wallThickness,
               endWallHeight,
                dgnModel
                );
            CreateGradualChange(
                commonChuteIn.Height * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BottomPaveThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BodySlope,
                commonChuteIn.SinkFlowWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallInterval * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftBottomCentreLength * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BaseEdgeThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.TopWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.GritBasinDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftWallSlopeRatio,
               culvertOpeningWidth,
               dgnModel
                );
            CreateGroove(
                commonChuteIn.Height * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BottomPaveThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BodySlope,
                commonChuteIn.SinkFlowWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallInterval * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftBottomCentreLength * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BaseEdgeThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.TopWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.GritBasinDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftWallSlopeRatio,
                culvertOpeningWidth,
                dgnModel
                );
            CreateConvergeWall(
                commonChuteIn.SinkFlowWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.SinkFlowWallLegth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.SinkFlowWallDiffusionRatio,
                commonChuteIn.CutoffWallWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.CutoffWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.Height * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BottomPaveThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BodySlope,
                commonChuteIn.EarWallInterval * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallHeight * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.EarWallWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftBottomCentreLength * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.BaseEdgeThickness * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.TopWidth * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.GritBasinDeep * 0.01 * GeneralHelpers.UorToMeters,
                commonChuteIn.ShaftWallSlopeRatio,
                culvertOpeningWidth,
               dgnModel
                );
        }

        /// <summary>
        /// 创建汇流墙
        /// </summary>
        /// <param name="convergeWallHeight">汇流墙高</param>
        /// <param name="convergeWallLength">汇流墙长</param>
        /// <param name="convergeWallRatio">汇流墙扩散比</param>
        /// <param name="interceptionWallWidth">截水墙宽</param>
        /// <param name="interceptionWallHeight">截水墙高</param>
        /// <param name="chuteHeight">急流槽高度</param>
        /// <param name="bottomPaveThickness">槽底铺砌厚度</param>
        /// <param name="aqueductBodySlopeRatio">槽体坡比</param>
        /// <param name="earWallInterval">耳墙间距</param>
        /// <param name="earWallHeight">耳墙高度</param>
        /// <param name="earWallWidth">耳墙宽度</param>
        /// <param name="centerLength">井底中心长</param>
        /// <param name="baseEdgeThickness">基础襟边厚度</param>
        /// <param name="wallSlopeRatio">井壁坡比</param>
        /// <param name="topWidth">槽顶宽度</param>
        /// <param name="deep">井深</param>
        /// <param name="gritBasinDeep">沉砂池深度</param>
        /// <param name="culvertOpeningWidth">涵洞口宽度</param>
        /// <param name="dgnModel">模型</param>
        private void CreateConvergeWall(double convergeWallHeight, double convergeWallLength, double convergeWallRatio, double interceptionWallWidth, double interceptionWallHeight,
            double chuteHeight, double bottomPaveThickness, double aqueductBodySlopeRatio, double earWallInterval, double earWallHeight, double earWallWidth,
            double centerLength, double baseEdgeThickness, double topWidth, double deep, double gritBasinDeep, double wallSlopeRatio, double culvertOpeningWidth, DgnModel dgnModel)
        {
            double exceedLength = centerLength + chuteHeight * aqueductBodySlopeRatio;//超出长度


            #region 右侧体
            //上面
            List<DPoint3d> rightTopDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5,-gritBasinDeep+chuteHeight+bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth,2)+Math.Pow(topWidth*convergeWallRatio,2)),-gritBasinDeep+chuteHeight+bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth,2)+Math.Pow(topWidth*convergeWallRatio,2)),-gritBasinDeep+chuteHeight+convergeWallHeight),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,-gritBasinDeep+chuteHeight+convergeWallHeight ),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,-gritBasinDeep + chuteHeight+bottomPaveThickness)
            };
            ShapeElement rightTopShape = new ShapeElement(dgnModel, null, rightTopDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            //截面拉伸
            LineElement lineElementLeft = new LineElement(dgnModel, null, new DSegment3d(new(), new(convergeWallLength, convergeWallLength * convergeWallRatio, 0)));
            //lineElementLeft.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightTopEntity, rightTopShape.GetCurveVector(), lineElementLeft.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutRightTop, rightTopEntity, null, dgnModel);
            //ehOutRightTop.AddToModel();
            this.Elements.Add(ehOutRightTop);
            #endregion


            #region 左侧体
            //上面
            List<DPoint3d> rightBottomDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + chuteHeight+bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth,2)+Math.Pow(topWidth*convergeWallRatio,2))),-gritBasinDeep + chuteHeight+bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth,2)+Math.Pow(topWidth*convergeWallRatio,2))),-gritBasinDeep + chuteHeight + convergeWallHeight),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + chuteHeight + convergeWallHeight ),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + chuteHeight+bottomPaveThickness)
            };
            ShapeElement rightBottomShape = new ShapeElement(dgnModel, null, rightBottomDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            LineElement lineElementRight = new LineElement(dgnModel, null, new DSegment3d(new(), new(convergeWallLength, -convergeWallLength * convergeWallRatio, 0)));
            //lineElementRight.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightBottomEntity, rightBottomShape.GetCurveVector(), lineElementRight.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutRightBottom, rightBottomEntity, null, dgnModel);
            //ehOutRightBottom.AddToModel();
            this.Elements.Add(ehOutRightBottom);
            #endregion

            #region 汇流铺砌
            //铺砌
            List<DPoint3d> paveDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))),-gritBasinDeep + chuteHeight + bottomPaveThickness),
                new(exceedLength+convergeWallLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio),-gritBasinDeep + chuteHeight+bottomPaveThickness),
                new(exceedLength+convergeWallLength,(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio),-gritBasinDeep + chuteHeight+bottomPaveThickness),
                new(exceedLength,(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))),-gritBasinDeep + chuteHeight + bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))),-gritBasinDeep + chuteHeight + bottomPaveThickness)
            };
            ShapeElement paveShape = new ShapeElement(dgnModel, null, paveDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            LineElement lineElementPave = new LineElement(dgnModel, null, new DSegment3d(new(), new(0, 0, -bottomPaveThickness)));
            //lineElementPave.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity paveEntity, paveShape.GetCurveVector(), lineElementPave.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutPave, paveEntity, null, dgnModel);
            //ehOutPave.AddToModel();
            this.Elements.Add(ehOutPave);
            #endregion

            #region 截水墙
            //截水墙
            List<DPoint3d> interceptionWallDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength+convergeWallLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio),-gritBasinDeep + chuteHeight),
                new(exceedLength+convergeWallLength,(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio),-gritBasinDeep + chuteHeight),

                new(exceedLength+convergeWallLength-interceptionWallWidth,(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio-interceptionWallWidth*convergeWallRatio),-gritBasinDeep + chuteHeight),
                new(exceedLength+convergeWallLength-interceptionWallWidth,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio-interceptionWallWidth*convergeWallRatio),-gritBasinDeep + chuteHeight),

                new(exceedLength+convergeWallLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+Math.Sqrt(Math.Pow(topWidth+baseEdgeThickness,2)+Math.Pow(topWidth+baseEdgeThickness*convergeWallRatio,2))+convergeWallLength*convergeWallRatio),-gritBasinDeep + chuteHeight),
            };
            ShapeElement interceptionWallShape = new ShapeElement(dgnModel, null, interceptionWallDPoint3Ds.ToArray());
            //interceptionWallShape.AddToModel();
            LineElement lineElementInterceptionWall = new LineElement(dgnModel, null, new DSegment3d(new(), new(0, 0, -interceptionWallHeight)));
            //lineElementInterceptionWall.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity interceptionWallEntity, interceptionWallShape.GetCurveVector(), lineElementInterceptionWall.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutInterceptionWall, interceptionWallEntity, null, dgnModel);
            //ehOutInterceptionWall.AddToModel();
            this.Elements.Add(ehOutInterceptionWall);
            #endregion
        }


        /// <summary>
        /// 创建槽体
        /// </summary>
        /// <param name="chuteHeight">急流槽高度</param>
        /// <param name="bottomPaveThickness">槽底铺砌厚度</param>
        /// <param name="aqueductBodySlopeRatio">槽体坡比</param>
        /// <param name="convergeWallHeight">汇流墙高</param>
        /// <param name="earWallInterval">耳墙间距</param>
        /// <param name="earWallHeight">耳墙高度</param>
        /// <param name="earWallWidth">耳墙宽度</param>
        /// <param name="centerLength">井底中心长</param>
        /// <param name="baseEdgeThickness">基础襟边厚度</param>
        /// <param name="wallSlopeRatio">井壁坡比</param>
        /// <param name="topWidth">槽顶宽度</param>
        /// <param name="deep">井深</param>
        /// <param name="gritBasinDeep">沉砂池深度</param>
        /// <param name="culvertOpeningWidth">涵洞口宽度</param>
        /// <param name="dgnModel">模型</param>
        private void CreateGroove(double chuteHeight, double bottomPaveThickness, double aqueductBodySlopeRatio, double convergeWallHeight, double earWallInterval, double earWallHeight, double earWallWidth,
            double centerLength, double baseEdgeThickness, double topWidth, double deep, double gritBasinDeep, double wallSlopeRatio, double culvertOpeningWidth, DgnModel dgnModel)
        {
            double exceedLength = centerLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio;//超出长度
            //槽底铺砌
            List<DPoint3d> bottomPaveDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth,-gritBasinDeep+deep-bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth,-(gritBasinDeep-bottomPaveThickness)+deep-bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth),-(gritBasinDeep-bottomPaveThickness)+deep-bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth),-gritBasinDeep+deep-bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth,-gritBasinDeep + deep - bottomPaveThickness)
            };
            ShapeElement bottomPaveShape = new ShapeElement(dgnModel, null, bottomPaveDPoint3Ds.ToArray());
            //bottomPaveShape.AddToModel();
            //截面拉伸
            LineElement lineElementbottomPave = new LineElement(dgnModel, null, new DSegment3d(new(), new((chuteHeight - (deep - bottomPaveThickness)) * aqueductBodySlopeRatio, 0, chuteHeight - (deep - bottomPaveThickness))));
            //lineElementbottomPave.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity bottomPaveEntity, bottomPaveShape.GetCurveVector(), lineElementbottomPave.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutbottomPave, bottomPaveEntity, null, dgnModel);
            //ehOutbottomPave.AddToModel();
            this.Elements.Add(ehOutbottomPave);
            #region 右侧体
            //上面
            List<DPoint3d> rightTopDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5,-gritBasinDeep+deep),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+topWidth,-gritBasinDeep+deep),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,-gritBasinDeep+deep+convergeWallHeight-bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,-gritBasinDeep+deep+convergeWallHeight-bottomPaveThickness ),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,-gritBasinDeep + deep)
            };
            ShapeElement rightTopShape = new ShapeElement(dgnModel, null, rightTopDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightTopEntity, rightTopShape.GetCurveVector(), lineElementbottomPave.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutRightTop, rightTopEntity, null, dgnModel);
            //ehOutRightTop.AddToModel();
            this.Elements.Add(ehOutRightTop);
            #endregion


            #region 左侧体
            //上面
            List<DPoint3d> rightBottomDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + deep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+topWidth),-gritBasinDeep + deep),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),-gritBasinDeep + deep + convergeWallHeight - bottomPaveThickness),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + deep + convergeWallHeight-bottomPaveThickness ),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),-gritBasinDeep + deep)
            };
            ShapeElement rightBottomShape = new ShapeElement(dgnModel, null, rightBottomDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightBottomEntity, rightBottomShape.GetCurveVector(), lineElementbottomPave.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutRightBottom, rightBottomEntity, null, dgnModel);
            //ehOutRightBottom.AddToModel();
            this.Elements.Add(ehOutRightBottom);
            #endregion
        }

        /// <summary>
        /// 创建渐变体
        /// </summary>
        /// <param name="chuteHeight">急流槽高度</param>
        /// <param name="bottomPaveThickness">槽底铺砌厚度</param>
        /// <param name="aqueductBodySlopeRatio">槽体坡比</param>
        /// <param name="convergeWallHeight">汇流墙高</param>
        /// <param name="earWallInterval">耳墙间距</param>
        /// <param name="earWallHeight">耳墙高度</param>
        /// <param name="earWallWidth">耳墙宽度</param>
        /// <param name="centerLength">井底中心长</param>
        /// <param name="baseEdgeThickness">基础襟边厚度</param>
        /// <param name="wallSlopeRatio">井壁坡比</param>
        /// <param name="topWidth">槽顶宽度</param>
        /// <param name="deep">井深</param>
        /// <param name="gritBasinDeep">沉砂池深度</param>
        /// <param name="culvertOpeningWidth">涵洞口宽度</param>
        /// <param name="dgnModel">模型</param>
        private void CreateGradualChange(double chuteHeight, double bottomPaveThickness, double aqueductBodySlopeRatio, double convergeWallHeight, double earWallInterval, double earWallHeight, double earWallWidth,
            double centerLength, double baseEdgeThickness, double topWidth, double deep, double gritBasinDeep, double wallSlopeRatio, double culvertOpeningWidth, DgnModel dgnModel)
        {
            double exceedLength = centerLength;//超出长度
            //槽底铺砌
            List<DPoint3d> bottomPaveDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio),-gritBasinDeep),
                new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth),-gritBasinDeep+deep-bottomPaveThickness),
                new(exceedLength+ (deep - bottomPaveThickness) * aqueductBodySlopeRatio,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth,-gritBasinDeep+deep-bottomPaveThickness),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep)

                //new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep),
                //new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-(gritBasinDeep-bottomPaveThickness)),
                //new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio),-(gritBasinDeep-bottomPaveThickness)),
                //new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio),-gritBasinDeep),
                //new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep)
            };
            ShapeElement bottomPaveShape = new ShapeElement(dgnModel, null, bottomPaveDPoint3Ds.ToArray());
            //bottomPaveShape.AddToModel();
            //截面拉伸
            LineElement lineElementbottomPave = new LineElement(dgnModel, null, new DSegment3d(new(), new(0, 0, bottomPaveThickness)));
            //LineElement lineElementbottomPave = new LineElement(dgnModel, null, new DSegment3d(new(), new(deep / aqueductBodySlopeRatio, 0, deep)));
            //lineElement.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity bottomPaveEntity, bottomPaveShape.GetCurveVector(), lineElementbottomPave.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutbottomPave, bottomPaveEntity, null, dgnModel);
            //ehOutbottomPave.AddToModel();
            this.Elements.Add(ehOutbottomPave);
            #region 右侧渐变
            //所有点
            DPoint3d dpRightFront1 = new(exceedLength, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5, -gritBasinDeep + bottomPaveThickness);
            DPoint3d dpRightFront2 = new(exceedLength, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth + deep * wallSlopeRatio, -gritBasinDeep + bottomPaveThickness);
            DPoint3d dpRightFront3 = new(exceedLength, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth, deep - (gritBasinDeep - bottomPaveThickness));
            DPoint3d dpRightFront4 = new(exceedLength, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5, deep - (gritBasinDeep - bottomPaveThickness));
            //List<DPoint3d> rightDPoint3Ds = new List<DPoint3d>() { dpRightFront1, dpRightFront2, dpRightFront3, dpRightFront4, dpRightFront5 };
            //ShapeElement rightShape = new ShapeElement(dgnModel, null, rightDPoint3Ds.ToArray());
            //rightShape.AddToModel();


            DPoint3d dpRightFront11 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5, -gritBasinDeep + deep);
            DPoint3d dpRightFront22 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth, -gritBasinDeep + deep);
            DPoint3d dpRightFront33 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth, -gritBasinDeep + deep + convergeWallHeight - bottomPaveThickness);
            DPoint3d dpRightFront44 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5, -gritBasinDeep + deep + convergeWallHeight - bottomPaveThickness);
            //List<DPoint3d> rightDPoint3Dss = new List<DPoint3d>() { dpRightFront11, dpRightFront22, dpRightFront33, dpRightFront44, dpRightFront11 };
            //ShapeElement rightShapes = new ShapeElement(dgnModel, null, rightDPoint3Dss.ToArray());
            //rightShapes.AddToModel();

            //创建面
            List<PolyfaceHeader> polyfaceHeaderRight = new List<PolyfaceHeader>()
            {
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront2,dpRightFront1,dpRightFront4,dpRightFront3},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront22,dpRightFront11,dpRightFront44,dpRightFront33},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront3,dpRightFront4,dpRightFront44,dpRightFront33},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront1,dpRightFront11,dpRightFront44,dpRightFront4},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront2,dpRightFront1,dpRightFront11,dpRightFront22},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpRightFront22, dpRightFront2, dpRightFront3, dpRightFront33},new())
            };
            MeshHeaderElement meshHeaderElementRight = DrawHelper.CraeteMeshHeaderElement(polyfaceHeaderRight);
            //meshHeaderElementRight.AddToModel();
            this.Elements.Add(meshHeaderElementRight);
            #endregion

            #region 左侧渐变
            //所有点 -(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+topWidth+(deep+gritBasinDeep)*wallSlopeRatio)
            DPoint3d dpLeftFront1 = new(exceedLength, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5), -gritBasinDeep + bottomPaveThickness);
            DPoint3d dpLeftFront2 = new(exceedLength, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth + deep * wallSlopeRatio), -gritBasinDeep + bottomPaveThickness);
            DPoint3d dpLeftFront3 = new(exceedLength, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth), deep - (gritBasinDeep - bottomPaveThickness));
            DPoint3d dpLeftFront4 = new(exceedLength, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5), deep - (gritBasinDeep - bottomPaveThickness));
            //List<DPoint3d> leftDPoint3Ds = new List<DPoint3d>() { dpLeftFront1, dpLeftFront2, dpLeftFront3, dpLeftFront4, dpLeftFront5 };
            //ShapeElement leftShape = new ShapeElement(dgnModel, null, leftDPoint3Ds.ToArray());
            //leftShape.AddToModel();


            DPoint3d dpLeftFront11 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5), -gritBasinDeep + deep);
            DPoint3d dpLeftFront22 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth), -gritBasinDeep + deep);
            DPoint3d dpLeftFront33 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + topWidth), -gritBasinDeep + deep + convergeWallHeight - bottomPaveThickness);
            DPoint3d dpLeftFront44 = new(exceedLength + (deep - bottomPaveThickness) * aqueductBodySlopeRatio, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5), -gritBasinDeep + deep + convergeWallHeight - bottomPaveThickness);
            //List<DPoint3d> leftDPoint3Dss = new List<DPoint3d>() { dpLeftFront11, dpLeftFront22, dpLeftFront33, dpLeftFront44, dpLeftFront11 };
            //ShapeElement leftShapes = new ShapeElement(dgnModel, null, leftDPoint3Dss.ToArray());
            //leftShapes.AddToModel();

            //创建面
            List<PolyfaceHeader> polyfaceHeaderLeft = new List<PolyfaceHeader>()
            {
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront2,dpLeftFront1,dpLeftFront4,dpLeftFront3},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront22,dpLeftFront11,dpLeftFront44,dpLeftFront33},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront3,dpLeftFront4,dpLeftFront44,dpLeftFront33},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront1,dpLeftFront11,dpLeftFront44,dpLeftFront4},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront2,dpLeftFront1,dpLeftFront11,dpLeftFront22},new()),
                DrawHelper.CreatePolyfaceHeader(new List<DPoint3d>(){ dpLeftFront22, dpLeftFront2, dpLeftFront3, dpLeftFront33},new())
            };
            MeshHeaderElement meshHeaderElementLeft = DrawHelper.CraeteMeshHeaderElement(polyfaceHeaderLeft);
            //meshHeaderElementLeft.AddToModel();
            this.Elements.Add(meshHeaderElementLeft);
            #endregion
        }


        /// <summary>
        /// 创建井
        /// </summary>
        /// <param name="centerLength">井底中心长</param>
        /// <param name="bottomSlope">井底纵坡</param>
        /// <param name="bottomBaseThickness">井底基础厚度</param>
        /// <param name="baseEdgeThickness">基础襟边厚度</param>
        /// <param name="wallSlopeRatio">井壁坡比</param>
        /// <param name="topWidth">槽顶宽度</param>
        /// <param name="deep">井深</param>
        /// <param name="gritBasinDeep">沉砂池深度</param>
        /// <param name="bottomPaveThickness">槽底铺砌厚度</param>
        /// <param name="Degrees">偏角</param>
        /// <param name="culvertOpeningWidth">涵洞口宽度</param>
        /// <param name="endWallHeight">端墙以上墙高</param>
        /// <param name="wallThickness">壁厚</param>
        /// <param name="dgnModel">模型</param>
        private void CreateWells(double centerLength, double bottomSlope, double bottomBaseThickness, double baseEdgeThickness, double wallSlopeRatio, double topWidth, double deep, double gritBasinDeep, double bottomPaveThickness, double Degrees, double culvertOpeningWidth, double wallThickness, double endWallHeight, DgnModel dgnModel)
        {
            //  管节内径+管壁厚+顶以上墙高
            double topEndWallHeight = culvertOpeningWidth * GeneralHelpers.UorToMeters + 1 * wallThickness * 0.01 * GeneralHelpers.UorToMeters + endWallHeight * 0.01 * GeneralHelpers.UnitsToMeters + gritBasinDeep;

            double exceedLength = 0;//超出长度
            if (Degrees != 0) exceedLength = -centerLength;
            #region 右侧体
            //底面
            List<DPoint3d> rightDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio,-gritBasinDeep-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-gritBasinDeep-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-gritBasinDeep)
            };
            ShapeElement rightShape = new ShapeElement(dgnModel, null, rightDPoint3Ds.ToArray());
            //rightShape.AddToModel();
            //截面拉伸
            LineElement lineElementBottom = new LineElement(dgnModel, null, new DSegment3d(new(), new(centerLength - exceedLength, 0, centerLength * bottomSlope / 1)));
            //lineElement.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightEntity, rightShape.GetCurveVector(), lineElementBottom.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);

            //上面
            List<DPoint3d> rightTopDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+topWidth+(deep+bottomPaveThickness)*wallSlopeRatio,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,deep-(gritBasinDeep-bottomPaveThickness)),
                //new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,topEndWallHeight),
                //new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,topEndWallHeight ),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,deep-(gritBasinDeep-bottomPaveThickness) ),
                new(exceedLength,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5,-gritBasinDeep)
            };
            ShapeElement rightTopShape = new ShapeElement(dgnModel, null, rightTopDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            //截面拉伸
            LineElement lineElement = new LineElement(dgnModel, null, new DSegment3d(new(), new(centerLength - exceedLength, 0, 0)));
            //lineElement.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightTopEntity, rightTopShape.GetCurveVector(), lineElement.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);

            #endregion


            #region 左侧体
            //底面
            List<DPoint3d> leftDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5-baseEdgeThickness),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+baseEdgeThickness+topWidth+(deep+gritBasinDeep)*wallSlopeRatio),-gritBasinDeep-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness),-gritBasinDeep-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness),-gritBasinDeep)
            };
            ShapeElement leftShape = new ShapeElement(dgnModel, null, leftDPoint3Ds.ToArray());
            //leftShape.AddToModel();
            //截面拉伸
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity leftEntity, leftShape.GetCurveVector(), lineElementBottom.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            //上面
            List<DPoint3d> rightBottomDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5+topWidth+(deep+bottomPaveThickness)*wallSlopeRatio),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),deep-(gritBasinDeep-bottomPaveThickness)),
                //new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),topEndWallHeight),
                //new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),topEndWallHeight ),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),deep-(gritBasinDeep-bottomPaveThickness) ),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5),-gritBasinDeep)
            };
            ShapeElement rightBottomShape = new ShapeElement(dgnModel, null, rightBottomDPoint3Ds.ToArray());
            //rightTopShape.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity rightBottomEntity, rightBottomShape.GetCurveVector(), lineElement.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            #endregion

            #region 井底铺砌
            //井底铺砌
            List<DPoint3d> gritBasionDPoint3Ds = new List<DPoint3d>()
            {
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5,-gritBasinDeep),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5,-(gritBasinDeep-bottomBaseThickness)),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5),-(gritBasinDeep-bottomBaseThickness)),
                new(exceedLength,-(culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5-baseEdgeThickness),-gritBasinDeep),
                new(exceedLength,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5-baseEdgeThickness),-(gritBasinDeep+(gritBasinDeep- bottomBaseThickness))),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-(gritBasinDeep+(gritBasinDeep- bottomBaseThickness))),
                new(exceedLength,culvertOpeningWidth* GeneralHelpers.UorToMeters*0.5-baseEdgeThickness,-gritBasinDeep)
            };
            ShapeElement gritBasionShape = new ShapeElement(dgnModel, null, gritBasionDPoint3Ds.ToArray());
            //gritBasionShape.AddToModel();
            //截面拉伸
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity gritBasionEntity, gritBasionShape.GetCurveVector(), lineElementBottom.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            #endregion

            DVector3d resultDvec = DVector3d.Zero;
            #region 角度线裁剪
            if (Degrees != 0)
            {


                double topleftDegrees = 90 - (180 - Degrees);
                Angle ang = Angle.FromDegrees(topleftDegrees);
                resultDvec = DVector3d.UnitX.RotateXY(Angle.FromDegrees(Degrees));
                //起点总宽
                double length = new DPoint3d(exceedLength, culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + baseEdgeThickness + topWidth + (deep + gritBasinDeep) * wallSlopeRatio, -gritBasinDeep - gritBasinDeep).Distance(
                    new(exceedLength, -(culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5 + baseEdgeThickness + topWidth + (deep + gritBasinDeep) * wallSlopeRatio), -gritBasinDeep - gritBasinDeep)
                    ) / 2;
                DPoint3d lineStaP = DPoint3d.Zero - resultDvec * (length / ang.Cos);
                //lineStaP.Z = (_sideDitchFallWell_ShaftDeep) * GeneralHelpers.UorToMeters;
                DPoint3d lineEndP = DPoint3d.Zero + resultDvec * (length / ang.Cos);
                //lineEndP.Z = lineStaP.Z;

                LineElement lineElementAngle = new LineElement(GeneralHelpers.Default3DModel, null, new DSegment3d(DPoint3d.Zero - resultDvec * length * 2 * 10, DPoint3d.Zero + resultDvec * length * 2 * 10));
                //lineElementAngle.AddToModel();

                BCIMNETGS.SolidUtil.Modify.CutSolidsWithCurves(out SolidKernelEntity[] solidKernelsRight, rightEntity, lineElementAngle.GetCurveVector(), SolidCutMethod.Split, SolidCutDirection.Both, SolidCutMode.Through, 0);
                BCIMNETGS.SolidUtil.Modify.CutSolidsWithCurves(out SolidKernelEntity[] solidKernelsRightTop, rightTopEntity, lineElementAngle.GetCurveVector(), SolidCutMethod.Split, SolidCutDirection.Both, SolidCutMode.Through, 0);
                BCIMNETGS.SolidUtil.Modify.CutSolidsWithCurves(out SolidKernelEntity[] solidKernelsLeft, leftEntity, lineElementAngle.GetCurveVector(), SolidCutMethod.Split, SolidCutDirection.Both, SolidCutMode.Through, 0);
                BCIMNETGS.SolidUtil.Modify.CutSolidsWithCurves(out SolidKernelEntity[] solidKernelsLeftTop, rightBottomEntity, lineElementAngle.GetCurveVector(), SolidCutMethod.Split, SolidCutDirection.Both, SolidCutMode.Through, 0);
                BCIMNETGS.SolidUtil.Modify.CutSolidsWithCurves(out SolidKernelEntity[] solidKernelsBasion, gritBasionEntity, lineElementAngle.GetCurveVector(), SolidCutMethod.Split, SolidCutDirection.Both, SolidCutMode.Through, 0);
                if (solidKernelsRight != null)
                {
                    //右底
                    Convert1.BodyToElement(out Element ehOutRight, solidKernelsRight[0], null, dgnModel);
                    //ehOutRight.AddToModel();
                    this.Elements.Add(ehOutRight);
                }
                if (solidKernelsRightTop != null)
                {
                    //右上
                    Convert1.BodyToElement(out Element ehOutRightTop, solidKernelsRightTop[0], null, dgnModel);
                    //ehOutRightTop.AddToModel();
                    this.Elements.Add(ehOutRightTop);
                }
                if (solidKernelsLeft != null)
                {
                    //左底
                    Convert1.BodyToElement(out Element ehOutLeft, solidKernelsLeft[0], null, dgnModel);
                    //ehOutLeft.AddToModel();
                    this.Elements.Add(ehOutLeft);
                }
                if (solidKernelsLeftTop != null)
                {
                    //左上
                    Convert1.BodyToElement(out Element ehOutRightBottom, solidKernelsLeftTop[0], null, dgnModel);
                    //ehOutRightBottom.AddToModel();
                    this.Elements.Add(ehOutRightBottom);
                }
                if (solidKernelsBasion != null)
                {
                    //铺砌
                    Convert1.BodyToElement(out Element ehOutgritBasion, solidKernelsBasion[0], null, dgnModel);
                    //ehOutgritBasion.AddToModel();
                    this.Elements.Add(ehOutgritBasion);
                }

            }
            else
            {
                //右底
                Convert1.BodyToElement(out Element ehOutRight, rightEntity, null, dgnModel);
                //ehOutRight.AddToModel();
                this.Elements.Add(ehOutRight);
                //右上
                Convert1.BodyToElement(out Element ehOutRightTop, rightTopEntity, null, dgnModel);
                //ehOutRightTop.AddToModel();
                this.Elements.Add(ehOutRightTop);
                //左底
                Convert1.BodyToElement(out Element ehOutLeft, leftEntity, null, dgnModel);
                //ehOutLeft.AddToModel();
                this.Elements.Add(ehOutLeft);
                //左上
                Convert1.BodyToElement(out Element ehOutRightBottom, rightBottomEntity, null, dgnModel);
                //ehOutRightBottom.AddToModel();
                this.Elements.Add(ehOutRightBottom);
                //铺砌
                Convert1.BodyToElement(out Element ehOutgritBasion, gritBasionEntity, null, dgnModel);
                //ehOutgritBasion.AddToModel();
                this.Elements.Add(ehOutgritBasion);
            }
            #endregion

            #region 顶部坡角
            double tempSlop = 1.5;
            //斜边长
            double c = topWidth / Math.Cos(Math.PI / 180 * (Degrees - 90));
            //对边长                                                                                                         
            double a = (topWidth + culvertOpeningWidth * GeneralHelpers.UorToMeters * 0.5) * Math.Tan(Math.PI / 180 * (Degrees - 90));
            //坡比偏移值
            double sideLen = (topEndWallHeight - deep + (gritBasinDeep - bottomPaveThickness)) * tempSlop;

            //拉伸线
            LineElement lineElementRightAngleProlong = new LineElement(dgnModel, null, new DSegment3d(new(), Degrees != 0 ? new DPoint3d() - resultDvec * c : new DPoint3d(0, -topWidth, 0)));
            //lineElementRightAngleProlong.AddToModel();
            LineElement lineElementLeftAngleProlong = new LineElement(dgnModel, null, new DSegment3d(new(), Degrees != 0 ? new DPoint3d() + resultDvec * c : new DPoint3d(0, topWidth, 0)));
            //lineElementLeftAngleProlong.AddToModel();

            //右侧
            List<DPoint3d> rightAngleDPoint3Ds = new List<DPoint3d>()
            {
                new(-(Degrees != 0 ?a:0),culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,deep-(gritBasinDeep-bottomPaveThickness)),
                new(-(Degrees != 0 ?a:0),culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,topEndWallHeight),
                new(sideLen-(Degrees != 0 ?a:0),culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,deep-(gritBasinDeep-bottomPaveThickness))
            };
            ShapeElement rightAngleShape = new ShapeElement(dgnModel, null, rightAngleDPoint3Ds.ToArray());
            //rightAngleShape.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity angleRightEntity, rightAngleShape.GetCurveVector(), lineElementRightAngleProlong.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutgritRightAngle, angleRightEntity, null, dgnModel);
            //ehOutgritRightAngle.AddToModel();
            this.Elements.Add(ehOutgritRightAngle);


            //左侧
            List<DPoint3d> leftAngleDPoint3Ds = new List<DPoint3d>()
            {
                new(Degrees == 0 ?0:a,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),deep-(gritBasinDeep-bottomPaveThickness)),
                new(Degrees == 0 ?0:a,-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),topEndWallHeight),
                new(sideLen+(Degrees == 0 ?0:a),-(culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth),deep-(gritBasinDeep-bottomPaveThickness)),
                //new(sideLen-a,culvertOpeningWidth * GeneralHelpers.UorToMeters*0.5+topWidth,topEndWallHeight-deep+(gritBasinDeep-bottomPaveThickness)),
            };
            ShapeElement leftAngleShape = new ShapeElement(dgnModel, null, leftAngleDPoint3Ds.ToArray());
            //leftAngleShape.AddToModel();
            BCIMNETGS.SolidUtil.Create.BodyFromSweep(out SolidKernelEntity angleLeftEntity, leftAngleShape.GetCurveVector(), lineElementLeftAngleProlong.GetCurveVector(), dgnModel, false, true, false, null, null, null, null);
            Convert1.BodyToElement(out Element ehOutgritLeftAngle, angleLeftEntity, null, dgnModel);
            //ehOutgritLeftAngle.AddToModel();
            this.Elements.Add(ehOutgritLeftAngle);
            #endregion
        }


    }
}

